<template>
    <div class="programModify">
        <el-form 
            ref="ruleForm" 
            label-width="100px"
            :model="ruleForm"
            :rules="rules">
            <el-form-item label="小程序名称" prop="appid">
                <el-select v-model="ruleForm.appid" placeholder="请选择小程序名称">
                    <el-option :label=item.appname :value=item.appid v-for="(item,index) in options" :key="index">{{item.appname}}</el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="渠道名称" prop="channel_name">
                <el-input v-model="ruleForm.channel_name"></el-input>
            </el-form-item>
            <el-form-item label="渠道跳转页" prop="channel_url">
                <el-select v-model="ruleForm.channel_url" placeholder="请选择渠道开始页">
                    <el-option label='index' value='index'>index</el-option>
                    <el-option label='start' value='start'>start</el-option>
                </el-select>
            </el-form-item>
        </el-form>
       <el-button @click="submitForm('ruleForm')" size="medium" class="addSubimit">提交</el-button>
    </div>
</template>
<script>
import { AddData,getChannel } from '@/assets/js'
export default {
    data(){
        return {
            options:[],//下拉
            ruleForm:{
                channel_name:'', //渠道
                appid:'',//下拉选中
                channel_url:''//渠道跳转页
            },
            rules:{
                appid:[
                    { required: true, message: '请输入活动名称', trigger: 'blur' }
                ],
                channel_name:[
                    { required: true, message: '请选择小程序名称', trigger: 'blur' }
                ],
                channel_url:[
                    { required: true, message: '请选择渠道开始页', trigger: 'blur' }
                ]
            }
        }
    },
    mounted:function(){
        getChannel(this)
    },
    methods:{
        submitForm:function(e){
            let data = {
                appid:this.ruleForm.appid,
                channel_name:this.ruleForm.channel_name,
                channel_url:this.ruleForm.channel_url,
            }
            AddData(this,e,data,'channel/addChannel')
        }
    }
}
</script>